home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Archive / Networking / AFP C++ / AFPSession.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  9.1 KB  |  398 lines  |  [TEXT/MPS ]

  1. /************************************************************
  2.  
  3. Created: Monday, Sept 23, 1991
  4.     AFPSession.h
  5.     C++ Interface to the AppleTalk Filing Protocol
  6.     M.Vierling
  7.  
  8.  
  9.         Copyright Apple Computer, Inc. 1985-1991
  10.         All rights reserved
  11.  
  12. ************************************************************/
  13.  
  14. #ifndef        AFPSession_H
  15. #define        AFPSession_H
  16.  
  17. #include <AppleTalk.h>
  18. #include "AFPCall.h"
  19.  
  20. enum {
  21.     afpChangePwd = 36,
  22.     afpGetUserInfo = 37,
  23.     afpGetSrvrMsg = 38,               /*AFPCall command codes*/
  24.     afpCreateID = 39,               /*AFPCall command codes*/
  25.     afpDeleteID = 40,                /*AFPCall command codes*/
  26.     afpResolveID = 41,                /*AFPCall command codes*/
  27.     afpExchangeFiles = 42,          /*AFPCall command codes*/
  28.     afpCatSearch = 43                /*AFPCall command codes*/
  29. };
  30.  
  31. typedef unsigned char PassWord[8];
  32.  
  33. struct Spec {
  34.  
  35.     Byte length;
  36.     Byte filler;
  37.     char data;
  38. };
  39.  
  40. #ifndef __FILES__
  41. struct CatPositionRec {
  42.  
  43.     long initialize;
  44.     short priv[6];
  45. };
  46. #endif
  47.  
  48. union OSInfo {
  49.  
  50.     char   FinderInfo[32];
  51.     struct
  52.     {
  53.         long fdType;
  54.         long fdCreator;
  55.     }fdInfo;
  56. };
  57.     
  58. struct FileDirBlock {
  59.  
  60.     short Attributes;
  61.     long ParentDirID;
  62.     long CreateDate;
  63.     long ModDate;
  64.     long BackupDate;
  65.     Byte FinderInfo[32];
  66.     short LongName;
  67.     short ShortName;
  68.     short FileDirFlag;
  69.     union {
  70.         struct {
  71.             long FileNumber;
  72.             long DataLength;
  73.             long RsrcLength;
  74.         } File;
  75.         struct {
  76.             long DirID;
  77.             short OffspringCount;
  78.             long OwnerID;
  79.             long GroupID;
  80.             long AccessRights;
  81.         } Dir;
  82.     };
  83.     short ProDOSFileType;
  84.     long ProDOSAuxType;
  85. };
  86.  
  87. AddrBlock FindServer( char * zoneName, char * serverName );
  88.  
  89. class TAFPSession : public TAFPCall
  90. {
  91. public:
  92.     TAFPSession();
  93.     ~TAFPSession();
  94.     OSErr ISession( AddrBlock theAddress );
  95.     
  96. // Accessors
  97.     AddrBlock GetAddress();
  98.     char * GetAFPVersion();
  99.     char GetPathDelimiter();
  100.     short GetVolumeID();
  101.     short GetForkID();
  102.     short GetIDNum();
  103.     short GetDTRefNum();
  104.     short GetUserID();
  105.     long GetDirID();
  106.     long GetMapID();
  107.     long GetActCount();
  108.     long GetOffset();
  109.     long GetFileID();
  110.     OSErr GetError();
  111.     Ptr GetReply();
  112.  
  113. // Mutators
  114.     void SetAddress( AddrBlock theAddress );
  115.     void SetPathDelimiter( char delimiter );
  116.     short SetVolumeID( short VolumeID );
  117.     short SetForkID( short OForkRefNum );
  118.     short SetDTRefNum( short DTRefNum );
  119.     short SetUserID( short UserID );
  120.     long SetDirID( long DirID );
  121.     long SetMapID( long MapID );
  122.     long SetFileID( long FileID );
  123.     void SetAFPVersion( char * version );
  124.  
  125.  
  126. // Server Calls
  127.     OSErr GetSrvrInfo();
  128.     OSErr GetSrvrParms();
  129.     OSErr GetSrvrMsg( short MsgType, short MsgBitmap );
  130.     OSErr LoginGuest();
  131.     OSErr LoginCleartxt( char * UserName, char * Password );
  132.     OSErr LoginRandnum( char * UserName, char * Password );
  133.     OSErr Login2Way( char * UserName, char * Password );
  134.     OSErr Login( char * AFPVersion,
  135.                  char * UAM,
  136.                  char * UserName,
  137.                  char * Password );
  138.     OSErr LoginCont( short IDNumber,
  139.                      char * UserAuthInfo,
  140.                      char * Password );
  141.     OSErr LoginCont2Way( short IDNumber,
  142.                          char * UserAuthInfo,
  143.                           char * Password,
  144.                          char * UserRandNum );
  145.     OSErr Logout();
  146.     OSErr MapID( long UserID, char FnType );
  147.     OSErr MapName( char * UserName, char FnType );
  148.     OSErr ChangePassword( char * UAM,
  149.                           char * UserName,
  150.                           char * OldPassword,
  151.                           char * NewPassword );
  152.     OSErr GetUserInfo( Byte ThisUserFlag, short, long UserID );
  153.  
  154.  
  155. // Volume Calls    
  156.     OSErr OpenVol( char * VolumeName, char * Password, short Bitmap );
  157.     OSErr CloseVol( short VolumeID );
  158.     OSErr GetVolParms( short VolumeID, short Bitmap );
  159.     OSErr SetVolParms( short VolumeID, short Bitmap, long BackupDate );
  160.     OSErr Flush( short VolumeID );
  161.     
  162.  
  163. // Directory Calls
  164.     OSErr SetDirParms( short VolumeID,
  165.                        long DirID,
  166.                        short Bitmap,
  167.                        Byte PathType,
  168.                        char * Pathname,
  169.                        FileDirBlock& theBlock );
  170.     OSErr OpenDir( short VolumeID,
  171.                    long DirID,
  172.                    Byte PathType,
  173.                    char * Pathname );
  174.  
  175.     OSErr CloseDir( short VolumeID, long DirID );
  176.     OSErr Enumerate( short VolumeID,
  177.                      long DirID,
  178.                      short FileBitmap,
  179.                      short DirBitmap,
  180.                      short ReqCount,
  181.                      short StartIndex,
  182.                      short MaxReplySize,
  183.                      Byte PathType,
  184.                      char * Pathname );
  185.     OSErr CreateDir( short VolumeID,
  186.                      long DirID,
  187.                      Byte PathType,
  188.                      char * Pathname );
  189.                      
  190.                      
  191. // File Calls
  192.     OSErr SetFileParms( short VolumeID,
  193.                         long DirID,
  194.                         short Bitmap,
  195.                         Byte PathType,
  196.                         char * Pathname,
  197.                         FileDirBlock& theBlock );
  198.     OSErr CreateFile( short VolumeID,
  199.                       long DirID, 
  200.                       Byte CreateFlag,
  201.                       Byte PathType,
  202.                       char * Pathname );
  203.     OSErr CopyFile( short SVolumeID,
  204.                     long SDirID,
  205.                     Byte SPathType,
  206.                     char * SPathname,
  207.                     short DVolumeID,
  208.                     long DDirID,
  209.                     Byte DPathType,
  210.                     char * DPathname,
  211.                     Byte NewType,
  212.                     char * NewName );
  213.     OSErr CreateID( short VolumeID,
  214.                     long DirID,
  215.                     Byte PathType,
  216.                     char * Pathname );
  217.     OSErr DeleteID( short VolumeID, long FileID );
  218.     OSErr ResolveID( short VolumeID,
  219.                      long FileID,
  220.                      short Bitmap );
  221.     OSErr ExchangeFiles( short VolumeID,
  222.                          long SrcDirID,
  223.                          long DestDirID,
  224.                          Byte SrcPathType,
  225.                          char * SrcPathname,
  226.                          Byte DestPathType,
  227.                          char * DestPathname );
  228.  
  229.  
  230. // Directory-File Calls
  231.  
  232.     OSErr GetFileDirParms( short VolumeID,
  233.                            long DirID,
  234.                            short FileBitmap,
  235.                            short DirBitmap,
  236.                            Byte PathType,
  237.                            char * Pathname );
  238.     OSErr SetFileDirParms( short VolumeID,
  239.                            long DirID,
  240.                            short Bitmap,
  241.                            Byte PathType,
  242.                            char * Pathname,
  243.                            FileDirBlock& theBlock );
  244.     OSErr Rename( short VolumeID,
  245.                   long DirID,
  246.                   Byte PathType,
  247.                   char * Pathname,
  248.                   Byte NewType,
  249.                   char * NewName );
  250.     OSErr Delete( short VolumeID,
  251.                   long DirID,
  252.                   Byte PathType,
  253.                   char * Pathname );
  254.     OSErr MoveAndRename( short VolumeID,
  255.                         long SrcDirID,
  256.                         long DestDirID,
  257.                         Byte SrcPathType,
  258.                         char * SrcPathname,
  259.                         Byte DestPathType,
  260.                         char * DestPathname,
  261.                         Byte NewType,
  262.                         char * NewName );
  263.     OSErr CatSearch( short VolumeID,
  264.                      long ReqMatches,
  265.                      CatPositionRec * CatPosition,
  266.                      short FileRsItBitmap,
  267.                      short DirRsltBitmap,
  268.                      short FPFlag,
  269.                      short ReqBitmap,
  270.                      FileDirBlock& Spec1,
  271.                      FileDirBlock& Spec2,
  272.                      char * longName );
  273.  
  274.  
  275. // Fork Calls -------------------------------------------------------
  276.  
  277.     OSErr GetForkParms( short OForkRefNum,
  278.                         short Bitmap );
  279.  
  280.     OSErr SetForkParms( short OForkRefNum,
  281.                         short Bitmap,
  282.                         long ForkLength );
  283.  
  284.     OSErr OpenFork(    Byte RsrcDataFlag,
  285.                     short VolumeID,
  286.                     long DirID,
  287.                     short Bitmap,
  288.                     short AccessMode,
  289.                     Byte PathType,
  290.                     char * Pathname );
  291.  
  292.     OSErr Read( short OForkRefNum,
  293.                 long Offset,
  294.                 long ReqCount,
  295.                 Byte NewlineMask,
  296.                 Byte NewlineChar,
  297.                 char * buffer );
  298.  
  299.     OSErr Write( short OForkRefNum,
  300.                 long Offset,
  301.                 long ReqCount,
  302.                 Byte StartEndFlag,
  303.                 char * buffer );
  304.  
  305.     OSErr FlushFork( short OForkRefNum );
  306.  
  307.     OSErr ByteRangeLock( Byte StartEndFlag,
  308.                          short OForkRefNum,
  309.                          long Offset,
  310.                          long Length );
  311.  
  312.     OSErr CloseFork( short OForkRefNum );
  313.  
  314.  
  315.  
  316. // Desktop Calls ---------------------------------------------------
  317.  
  318.     OSErr OpenDT( short VolumeID );
  319.     OSErr CloseDT( short DTRefNum );
  320.     OSErr AddIcon(  short DTRefNum,
  321.                     ResType FileCreator,
  322.                     ResType FileType,
  323.                     Byte IconType,
  324.                     ResType IconTag,
  325.                     short BitmapSize,
  326.                     Ptr IBitmapPtr );
  327.     OSErr GetIcon(    short DTRefNum,
  328.                     ResType FileCreator,
  329.                     ResType FileType,
  330.                     Byte IconType,
  331.                     short Length );
  332.     OSErr GetIconInfo(     short DTRefNum,
  333.                         ResType FileCreator,
  334.                         short IconIndex );
  335.     OSErr AddAPPL(  short DTRefNum,
  336.                     long DirID,
  337.                     ResType FileCreator,
  338.                     ResType APPLTag,
  339.                     short PathType,
  340.                     char * Pathname );
  341.     OSErr RemoveAPPL( short DTRefNum,
  342.                       long DirID,
  343.                       ResType FileCreator,
  344.                       short PathType,
  345.                       char * Pathname );
  346.     OSErr GetAPPL( short DTRefNum,
  347.                    ResType FileCreator,
  348.                    short APPLIndex,
  349.                    short Bitmap );
  350.     OSErr AddComment( short DTRefNum,
  351.                       long DirID,
  352.                       Byte PathType,
  353.                       char * Pathname,
  354.                       char * Comment );
  355.     OSErr RemoveComment( short DTRefNum,
  356.                          long DirID,
  357.                          Byte PathType,
  358.                          char * Pathname );
  359.     OSErr GetComment( short DTRefNum,
  360.                       long DirID,
  361.                       Byte PathType,
  362.                       char * Pathname );
  363.  
  364. private:
  365.     AddrBlock        fafpAddrBlock;
  366.     char            fAFPVersion[17];
  367.     char            fPathDelimiter;
  368.     unsigned  short        fCBSize,
  369.                         fRBSize;                
  370.     short            fVolumeID;
  371.     short            fOForkRefNum;
  372.     short            fDTRefNum;
  373.     long            fDirID;
  374.     long            fMapID;
  375.     long            fFileID;
  376.     long            fActCount;
  377.     long            fOffset;
  378.     Ptr                fCBptr,
  379.                     fRBptr;
  380.     Ptr                fCBStart;
  381.     Ptr                fRBStart;
  382.     
  383.     void bytePush( Byte aByte );
  384.     void shortPush( short theShort );
  385.     void longPush( long theLong );
  386.     void stringPush( char * stringName );
  387.     void passwordPush( char * Password );
  388.     void passwordCreate( PassWord * password, char * string );
  389.     void desPush( PassWord * Key, PassWord * Password, Boolean useNewDES );
  390.     void fileDirPush( short Bitmap, FileDirBlock& theBlock );
  391.     void specPush( short Bitmap, FileDirBlock& theBlock, char * string );
  392.     void pathPush( Byte PathType, char * Pathname );
  393.     void arrayPush( char * arrayName, unsigned int arrayLen );
  394.     void alignPush();
  395.     OSErr MakeAFPCall();
  396. };
  397.  
  398. #endif